package double_pointer;

public class maxArea {
    public int maxArea(int[] height) {

        int left = 0;
        int right = height.length-1;
        int max = Integer.MIN_VALUE;
        while(left < right) {
            int minindex = Math.min(height[left],height[right]);
            int sum = (right - left)*minindex;
            if(minindex == height[left]) {
                left++;
            }else {
                right--;
            }
            max = Math.max(sum,max);
        }
        return max;
    }
}
